package com.yjhb.android.sbz.mvp.login;

import com.yjhb.android.sbz.entity.UserInfo;
import com.yjhb.android.sbz.http.HttpObserver;
import com.yjhb.android.sbz.http.HttpTool;
import com.jojo.android.zxlib.tool.ZxEncryptTool;

/**
 * 创建者 zx
 * 创建时间 2021/2/21 11:42
 */
public class AccountLoginPresenter extends LoginPresenter<LoginView> {
    private final String TAG = "AccountLoginPresenter";

    public AccountLoginPresenter(LoginView loginView) {
        super(loginView);
    }

    @Override
    protected void onDestroy() {

    }


    public void login(String account, String password) {
        if (view != null) {
            view.loggingIn();
        }
        password = ZxEncryptTool.encryptMD5ToString(password).toUpperCase();
        HttpTool.request(model.loginForWeb(account, password,"13569842"), new HttpObserver<UserInfo>() {
            @Override
            public void onResult(UserInfo data) {
                if (view != null) {
                    view.onLoginSuccess(data);
                }
            }

            @Override
            public void onError(int code, String msg) {
                if (view != null) {
                    view.onFailure(code, msg);
                }
            }
        });
    }

}
